//
//  PropertyTool.m
//  HelloMusic
//
//  Created by mac on 15/3/19.
//  Copyright (c) 2015年 gpr. All rights reserved.
//

#import "PropertyTool.h"

@implementation PropertyTool

static NSString *COPY_PROPERTY = @"@property (nonatomic,copy) NSString *%@;";
static NSString *ASSIGN_PROPERTY = @"@property (nonatomic,assign) NSInteger %@;";

+ (void)propertyInfoWithDict:(NSDictionary *)dict {
    NSMutableString *result = [NSMutableString string];
    [result appendString:@"\n"];
    [dict enumerateKeysAndObjectsUsingBlock:^(id key, id obj, BOOL *stop) {
        NSString *str = NSStringFromClass([obj class]);
        if ( [str isEqualToString:@"__NSCFString"] || [str isEqualToString:@"__NSCFConstantString"]) {
            [result appendString:[NSString stringWithFormat:COPY_PROPERTY,key]];
        } else if ( [str isEqualToString:@"__NSCFNumber"] ) {
            [result appendString:[NSString stringWithFormat:ASSIGN_PROPERTY,key]];
        }
        [result appendString:@"\n"];
    }];
    [result appendString:@"\n"];
    NSLog(@"%@",result);
}

@end
